Reinitialize producer and consumer index to 0 if indexes corruption are detected
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Fri, 17 Mar 2006 10:03:37 +0000 (10:03 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Fri, 17 Mar 2006 10:03:37 +0000 (10:03 +0000)
in XenBus.
Prevent a kernel infinite loop and add more recovering ability.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c

index 6d06b4dc1ecfbd911587472bfefb014fceb60936..dac34e4e0f152d9934bc22f59b00d2d66466e1d8 100644 (file)
@@ -106,8 +106,10 @@ int xb_write(const void *data, unsigned len)
                cons = intf->req_cons;
                prod = intf->req_prod;
                mb();
-               if (!check_indexes(cons, prod))
+               if (!check_indexes(cons, prod)) {
+                       intf->req_cons = intf->req_prod = 0;
                        return -EIO;
+               }
 
                dst = get_output_chunk(cons, prod, intf->req, &avail);
                if (avail == 0)
@@ -150,8 +152,10 @@ int xb_read(void *data, unsigned len)
                cons = intf->rsp_cons;
                prod = intf->rsp_prod;
                mb();
-               if (!check_indexes(cons, prod))
+               if (!check_indexes(cons, prod)) {
+                       intf->rsp_cons = intf->rsp_prod = 0;
                        return -EIO;
+               }
 
                src = get_input_chunk(cons, prod, intf->rsp, &avail);
                if (avail == 0)